﻿@{
    Layout = null;
    ViewBag.Title = "归档材料类型选择弹出框";
}
<div class="pageContent" layouth="38">
    <form method="post" action="demo/common/ajaxDone.html" class="pageForm required-validate" onsubmit="return validateCallback(this,dialogAjaxDone)" layouth="38">
        <div id="div_project_ftype_zTree" style="display: none; margin-left: 10px; margin-top: 10px;">无下级分类</div>
        <ul id="project_ftype_zTree" class="ztree">
        </ul>
    </form>
</div>
<div class="formBar">
    <ul>
        <li>
            <button type="button" class="btn btn-success btn-sm" onclick="project_ftype_zTree_typeSel()">
                选择</button>
        </li>
        <li>
            <button type="button" class="close btn btn-default btn-sm" onclick="typeCancel()">
                取消</button>
        </li>
    </ul>
</div>
<script type="text/javascript">
    var project_ftype_zTree;
    var project_ftype_zTree_setting;

    var project_ftype_zTree_setting = {
        treeObjId: "project_ftype_zTree",
        isSimpleData: true,              //数据是否采用简单 Array 格式，默认false
        treeNodeKey: "id",               //在isSimpleData格式下，当前节点id属性
        treeNodeParentKey: "pId",        //在isSimpleData格式下，当前节点的父节点id属性
        showLine: true,                  //是否显示节点间的连线
        checkable: true,                 //每个节点上是否显示 CheckBox
        checkStyle: "checkbox",   //多选 checkbox   单选 radio
        async: true,
        asyncUrl: "/CompletionMaterials/FileList/AsyncSelectJson",  //获取节点数据的URL地址
        asyncParam: ["proId", "id"],
        callback: {
            change: project_ftype_zTree_change
        }
    };
    $(document).ready(function () {
        $.getJSON(
          "/CompletionMaterials/FileList/AsyncSelectJson?proId=@(ViewBag.proId)&id=@(ViewBag.id)",
           function (data) {
               if (data.length == 0)
                   $("#div_project_ftype_zTree").show();
               else {
                   $("#div_project_ftype_zTree").hide();
                   project_ftype_zTree = $("#project_ftype_zTree").zTree(project_ftype_zTree_setting, data);
               }
           });
    });
    function project_ftype_zTree_change(event, treeId, treeNode) {
        if (treeNode.checked) {
            $.post("/CompletionMaterials/FileList/TempSelect", { proId: treeNode.proId, pId: "@(ViewBag.id)", id: treeNode.id }, "", "json");
        }
        else {
            $.post("/CompletionMaterials/FileList/TempDelete", { proId: treeNode.proId, id: treeNode.id }, "", "json");
            alertMsg.info("将同时删除与其关联的案卷信息,请谨慎操作！");
            //alertMsg.confirm("将同时删除与其关联的案卷信息，您确定要排除吗？", {
            //    okCall: function () {
            //        $.post("/CompletionMaterials/FileList/TempDelete", { proId: treeNode.proId, id: treeNode.id }, "", "json");
            //    },
            //    cancelCall: function () {
            //        treeNode.checked = true;
            //        project_ftype_zTree.updateNode(treeNode);
            //    }
            //});
        }
    }
    function project_ftype_zTree_typeSel() {
        $.post("/CompletionMaterials/FileList/SelectPost", { type: "sel", proId: "@(ViewBag.proId)", id: "@(ViewBag.id)" }, refre_jgzl_ajml_index, "json");
        $.pdialog.closeCurrent();
    }
    function typeCancel() {
        $.post("/CompletionMaterials/FileList/SelectPost", { type: "cancel", proId: "@(ViewBag.proId)", id: "@(ViewBag.id)" }, refre_jgzl_ajml_index, "json");
    }
</script>

